package com.kara.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.appfuse.model.BaseObject;

@Entity
@Table(name="school_year")
public class SchoolYear extends BaseObject implements Serializable{

	private Long id;
	private Date startDate;
	private Date endDate;
	private boolean isCurrentSchoolYear;
	
	public SchoolYear(long id) {
		this.id = id;
	}
	
	public SchoolYear() {
	}
	
	@Id
	@SequenceGenerator(name = "EMP_SEQ_GEN", sequenceName = "emp_sequence")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EMP_SEQ_GEN")
	public Long getId() {
		return id;
	}
	@Column(name="start_date", nullable=false)
	@Temporal(TemporalType.DATE)
	public Date getStartDate() {
		return startDate;
	}
	
	@Column(name="end_date", nullable=false)
	@Temporal(TemporalType.DATE)
	public Date getEndDate() {
		return endDate;
	}
	@Column(name="is_current", nullable=false)
	public Boolean getIsCurrentSchoolYear() {
		return isCurrentSchoolYear;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	public void setCurrentSchoolYear(boolean isCurrentSchoolYear) {
		this.isCurrentSchoolYear = isCurrentSchoolYear;
	}
	public void setStartDate(Date dateStart) {
		this.startDate = dateStart;
	}
	public void setEndDate(Date dateEnd) {
		this.endDate = dateEnd;
	}
	public void setIsCurrentSchoolYear(Boolean isCurrentSemester) {
		this.isCurrentSchoolYear = isCurrentSemester;
	}
	
	@Override
	public String toString() {
		return new ToStringBuilder(SchoolYear.class)
		.append("id", id)
		.append("start_date", startDate)
		.append("end_date", endDate)
		.append("isCurrentSchoolYear", isCurrentSchoolYear).toString();	
	}
	
	@Override
	public boolean equals(Object o) {
		if (o == null){
			return false;
		}
		if (!(o instanceof SchoolYear) ){
			return false;
		}
		if (((SchoolYear)o).getId().equals(getId())){
			return true;
		}
		return false;
	}
	@Override
	public int hashCode() {
		return this == null ? 0 : getId().hashCode();
	}
}
